package com.c2c.mapper;

import com.c2c.po.Complaint;
import com.c2c.po.enums.impl.ComplaintsState;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ComplaintMapper {

    /**
     * 查看所有投诉   此处理论上只有管理员调用
     *
     * @return 返回所有投诉信息
     */
//    @Select("select * from complaint")
    List<Complaint> findAllComplaint();

    /**
     * 查看对应投诉
     * @param complaintId       投诉Id
     * @return                  对应投诉内容
     */
//    @Select("select * from complaint where complaintId = #{complaintId}")
    Complaint findComplaintByComplaintId(int complaintId);

    /**
     * 根据用户Id查找投诉的举报信息
     *
     * @return 返回所有投诉信息
     */
//    @Select("select * from complaint where userAccount = #{userAccount}")
    List<Complaint> findComplaintByUserAccount(int userAccount);

    /**
     * 根据用户Id查找投诉的信息
     *
     * @return 返回所有投诉信息
     */
//    @Select("select * from complaint where orderId in " +
//            "(select orderId from `order` o where o.goodsId in " +
//            "(select goodsId from goods where goods.userAccount = #{userAccount}))")
    List<Complaint> findComplaintByAccount(int userAccount);

    /**
     * 根据状态查询投诉信息
     *
     * @param complaintsState         Complaint状态
     * @return                        查询的内容
     */
//    @Select("select * from complaint where complaintState = #{complaintState}")
    List<Complaint> findComplaintByState(ComplaintsState complaintsState);

    /**
     * 管理员处理后会修改这些数据
     *
     * @param complaint               封装内容
     */
//    @Update("update complaint set complaintState = #{complaintState} ,adminId = #{adminId} where complaintId = #{complaintId}")
    void updateComplaintByComplaintId(Complaint complaint);

    /**
     * 新增投诉
     * @param complaint               封装内容
     */
//    @Insert("insert into complaint(complaintId, complaintTime , complaintReason, complaintState, userAccount, orderId) " +
//            "values(#{complaintId}, #{complaintTime}, #{complaintReason}, 1, #{userAccount}, #{orderId})")
    void insertComplaint(Complaint complaint);


}
